package com.alibaba.define.enums;

import lombok.Getter;

/**
 * @author : hanyang
 * @date : 2023-10-29 19:41
 **/

@Getter
public enum AppHttpCodeEnum {
    //成功
    SUCCESS(200, "操作成功"),
    //登陆
    NEED_LOGIN(401, "需要登陆后操作"),
    NO_OPERATOR_AUTH(403, "无操作权限"),
    SYSTEM_ERROR(500,"系统错误"),
    USERNAME_EXIST(501,"用户名已存在"),
    PHONE_NUMBER_EXIST(502,"手机号已存在"),
    EMAIL_EXIST(503, "邮箱已存在"),
    REQUIRE_USERNAME(504, "必需填写用户名"),
    LOGIN_ERROR(505,"用户名或密码错误"),
    REGISTER_FAILED(506, "注册失败"),


    WRONG_PARAMETER(1000, "请求参数有误"),
    SYSTEM_EXECUTE_ERROR(1001, "系统执行异常"),
    QUERY_RESULT_NULL(1002, "查询结果为空"),
    ADD_FAIL(1003, "新增失败"),
    HAS_SENSITIVE_WORD(1004, "评论内容中有敏感词"),
    FILE_TOO_LARGE(1005, "文件大小超限"),
    UN_KNOWN_FILE_TYPE(1006, "未知文件类型"),
    NOT_SUPPORT_THIS_IMAGE_TYPE(1007, "不支持该类型图片上传！"),
    UPDATE_FAILED(1008, "更新失败");


    private final int code;
    private final String msg;

    AppHttpCodeEnum(int code, String errorMessage) {
        this.code = code;
        this.msg = errorMessage;
    }

    public static String getName(int code) {
        for (AppHttpCodeEnum value : AppHttpCodeEnum.values()) {
            if (code == value.code) {
                return value.msg;
            }
        }
        return null;
    }
}
